/*
 * PopupImageViewerFx.h
 *
 *  Created on: Jul 6, 2013
 *      Author: guillou
 */

#ifndef POPUPIMAGEVIEWERFX_H_
#define POPUPIMAGEVIEWERFX_H_

#include <QPainter>
#include "PopupImage.hpp"
#include "PopupImageViewer.hpp"

struct PopupImageFx
{
  PopupImageFx(PopupImage *p_image) : m_fxTarget(p_image) {}
  virtual ~PopupImageFx() {};
  virtual bool apply() { return false; }
  virtual bool paint(QPainter &) { return false; }

protected:
  PopupImage *m_fxTarget;
  PopupImageFx(const PopupImageFx &) {}
};

struct PopupTransitionFx : public PopupImageFx
{
  PopupTransitionFx(PopupImage *p_image);
  bool apply();

private:
  PopupGui::Transition transition;
  int xshift;
  int yshift;
  int speed;
};

struct PopupOpacityFx : public PopupImageFx
{
  PopupOpacityFx(PopupImage *p_image) : PopupImageFx(p_image),
      opacity(0.0) {
    m_fxTarget->parent->setWindowOpacity(opacity);
  }

  bool apply() {
    opacity += 0.01;
    m_fxTarget->parent->setWindowOpacity(opacity);
    return (opacity < 1.0);
  }

private:
  qreal opacity;
};

struct PopupZoomFx : public PopupImageFx
{
  PopupZoomFx(PopupImage *p_image);
  bool apply();

private:
  float xgrow;
  float ygrow;
  float x;
  float y;
  float w;
  float h;
};


struct PopupImageTextOverlayFx : public PopupImageFx
{
  PopupImageTextOverlayFx(PopupImage *p_image) : PopupImageFx(p_image) {}
  virtual bool paint(QPainter & p_painter);
};

#endif /* POPUPIMAGEVIEWERFX_H_ */
